import { IMenu } from '@/api/menu/type'
import http from '@/utils/http'
import authMenuList from "@/assets/json/authMenuList.json";

// 菜单相关接口
export class MenuApi {
  // 列表
  static list = () => http.post<IMenu.MenuForm[]>('/admin/menu/index')

  // 编辑和创建
  static edit = (params: Omit<IMenu.MenuForm, 'children'>) => http.post<{ id: number }>('/admin/menu/edit', params)

  // 删除
  static delete = (params: { ids: number[] }) => http.post('/admin/menu/delete', params)
  
  // 角色菜单
  static getAuthMenuList = () => {
    return http.post<Menu.MenuOptions[]>('/admin/menu/index')

     // 如果想让菜单变为本地数据，注释上一行代码，并引入本地 authMenuList.json 数据
    return authMenuList;
  }
}
